package com.dt.dubai.core.xml;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import java.io.StringReader;

public class JAXBTest {
    public static void main(String[] args) throws JAXBException {
        JAXBContext context = JAXBContext.newInstance(BoyBean.class);

        Marshaller marshaller = context.createMarshaller();
        Unmarshaller unmarshaller = context.createUnmarshaller();
        BoyBean boyBean = new BoyBean();
        marshaller.marshal(boyBean, System.out);
        System.out.println();
        String xml = "<boyBean><name>David</name></boyBean>";
        BoyBean boyBean2 = (BoyBean) unmarshaller.unmarshal(new StringReader(xml));
        System.out.println(boyBean2.name);
    }


}
